]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
extensionSystem: Always disable multiple extensions in reverse order
authorJonas Dreßler <verdre@v0yd.nl>
Mon, 19 Nov 2018 11:26:16 +0000 (12:26 +0100)
committerFlorian Müllner <florian.muellner@gmail.com>
Thu, 12 Sep 2019 10:24:49 +0000 (10:24 +0000)
Since disabling an extension will lead to disabling and re-enabling all
following extensions in the list, always disable multiple extensions by
looping through the list in reverse order.

This lowers the execution time of the event handlers quite a bit if many
extensions are installed.

Thanks to Philippe Troin for identifying the problem and proposing the
initial patch to change the extension order when reloading.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/177

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/96

js/ui/extensionSystem.js

index 714537b5d2938a501ee3d17955926ee9786d5153..7fe275ec7b3c7b51a06e41812cf90f113bb70da8 100644 (file)
@@ -400,9 +400,9 @@ var ExtensionManager = class {
 
         // Find and disable all the newly disabled extensions: UUIDs found in the
         // old setting, but not in the new one.
-        this._enabledExtensions.filter(
-            item => !newEnabledExtensions.includes(item)
-        ).forEach(uuid => {
+        this._extensionOrder.filter(
+            uuid => !newEnabledExtensions.includes(uuid)
+        ).reverse().forEach(uuid => {
             this._callExtensionDisable(uuid);
         });
 
@@ -417,20 +417,19 @@ var ExtensionManager = class {
     }
 
     _onVersionValidationChanged() {
-        // we want to reload all extensions, but only enable
-        // extensions when allowed by the sessionMode, so
-        // temporarily disable them all
-        this._enabledExtensions = [];
-
-        // The loop modifies the extensions map, so iterate over a copy
-        let extensions = [...this._extensions.values()];
-        for (let extension of extensions)
-            this.reloadExtension(extension);
-        this._enabledExtensions = this._getEnabledExtensions();
+        // Disabling extensions modifies the order array, so use a copy
+        let extensionOrder = this._extensionOrder.slice();
 
-        this._enabledExtensions.forEach(uuid => {
-            this._callExtensionEnable(uuid);
+        // Disable enabled extensions in the reverse order first to avoid
+        // the "rebasing" done in _callExtensionDisable...
+        extensionOrder.slice().reverse().forEach(uuid => {
+            this._callExtensionDisable(uuid);
         });
+
+        // ...and then reload and enable extensions in the correct order again.
+        [...this._extensions.values()].sort((a, b) => {
+            return extensionOrder.indexOf(a.uuid) - extensionOrder.indexOf(b.uuid);
+        }).forEach(extension => this.reloadExtension(extension));
     }
 
     _loadExtensions() {